Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Perf] Reserve the exact capacity in ToBits for BigIntegers #2514

Merged
merged 1 commit into from
Oct 18, 2024

Conversation

ljedrz
Copy link
Collaborator

@ljedrz ljedrz commented Jul 9, 2024

While heap-profiling the loading of the Canary ledger, I was surprised by the number of temporary allocations pointing to the ToBits impl for BigInteger256; it appears that the Extend impl that's used there is not able to take advantage of the ExactSizeIterator impl for BitIteratorLE, and we need to be more explicit in order to avoid them.

The results at height 330598 are as follows:

  • total allocs -14%
  • temp allocs: -28%
  • ledger loading time: -9%

@ljedrz
Copy link
Collaborator Author

ljedrz commented Jul 9, 2024

CI run link

Copy link
Contributor

@vicsn vicsn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Color me surprised as well. Cool find.

@zosorock zosorock merged commit 9c24b45 into AleoNet:staging Oct 18, 2024
76 of 83 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants